package com.chuangke.sinotrukbudgetapi.config;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.alibaba.fastjson2.JSON;
import com.chuangke.common.SpringContextUtil;
import com.chuangke.common.utils.FileUtils;

public class ZgzqPoConfigUtil {

	private static Map<String, ZgzqPoConfig> configMap = new HashMap<>();
	static {
		PoProperties poProperties = (PoProperties) SpringContextUtil
				.getBean(PoProperties.class);
		String file = FileUtils.getFileStr("classpath:"+poProperties.getFile());
		List<ZgzqPoConfig> list = JSON.parseArray(file, ZgzqPoConfig.class);
		configMap = list.stream().collect(Collectors.toMap(ZgzqPoConfig::getInterfaceId, a -> a));
	}
	
	public static ZgzqPoConfig getConfig(String interfaceId) {
		return configMap.get(interfaceId) ;
	}
}
